<template>
  <div class="app"> 
    <!-- template中ref对象自动解包 -->
    <h2>当前计数：{{ counter }}</h2>
    <button @click="increment">+1</button>
    <button @click="decrement">-1</button>
  </div>
</template>

<script>
import {ref} from 'vue'
import useCounter from './hooks/useCounter'
export default {
 setup(){
  // 1.定义counter的内容
  // 默认定义的数据都不是响应式数据
  // const { counter , increment, decrement} = useCounter()
  // let counter = ref(0)
  // const increment = () =>{
  //   console.log('increment');
  //   counter.value++
  // }
  // const decrement = ()=>{
  //   console.log('decrement');
  //   counter.value--
  // }

  return {
   ...useCounter()
  }
 }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
